package javase.javase02.Annotation;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

/**
 * @author: Gan
 * @date 2021/4/18 0018 10:25
 * @description:
 **/
public class second {
    public static void main(String[] args) throws IOException {
        String str = "我要买下斯台普斯";
        OutputStreamWriter outputStreamWriter;
        outputStreamWriter = new OutputStreamWriter(new FileOutputStream("a.txt"));
        outputStreamWriter.write(str);
        outputStreamWriter.write("\r");
        writeSingle(str, outputStreamWriter);
        writeMulti(str, outputStreamWriter);
        outputStreamWriter.close();
    }

    private static void writeSingle(String str, OutputStreamWriter outputStreamWriter) throws IOException {
        char[] chars = str.toCharArray();
        outputStreamWriter.write(chars);

    }

    private static void writeMulti(String str, OutputStreamWriter outputStreamWriter) throws IOException {
        char[] chars = str.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            outputStreamWriter.write(chars[i]);
        }
    }
}
